package com.example.demo1.user.entity;

import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

/**
 * 用于存放所有与地图相关的信息
 */
public class DrawGridPane {

    private Stage stage;
    // 使用二维数组存放地图上的所有位置,5行9列
    private int[][] mapRoom = new int[10][5];

    public GridPane drawGrid() {
        // 绘制网格
        javafx.scene.layout.GridPane gridPane = new javafx.scene.layout.GridPane();

//        gridPane.setMinSize(550, 300);  // 将网格设置为长宽均为60的格子
        gridPane.setLayoutX(0);
        gridPane.setLayoutY(90);
        gridPane.setHgap(5);
        gridPane.setVgap(5);
        gridPane.setPadding(new Insets(10));
//        gridPane.setStyle("-fx-background-color: black; ");
        // 循环向网格中添加数据
        for (int i = 0; i < mapRoom.length; i++) {
            for (int j = 0; j < mapRoom[i].length; j++) {
                Button btn = new Button();
                if (i == 0) {
                    btn.setStyle("-fx-min-width: 30;-fx-min-height: 80");
                    gridPane.add(btn, i + 1, j + 1);
                    continue;
                }
                btn.setStyle("-fx-background-color: white;-fx-min-width: 75;-fx-min-height: 90");
                gridPane.add(btn, i + 1, j + 1);
            }
        }
        return gridPane;
    }

    /**
     * 用于获取到当前的地理位置
     *
     * @return 坐标
     */
    public String getCoordinate() {

        return null;
    }
}
